﻿@model Data.Web.News
 
@{
    var Upload = System.Configuration.ConfigurationManager.AppSettings["Upload"];
    
}
@section head {
     
	<script src="/Libs/ckeditor/ckeditor.js"></script>   
	<script type="text/javascript">
	    $(document).ready(function(){ 
	        CKEDITOR.replace('Content', {
                       language: 'vi'

                   }); 
	        


	    

	            $("form").submit(function () {
	                var selTypeText = $("#UserId option:selected").text();
	                selTypeText = selTypeText.replace(/_/gi, '');
	                $("#UserName").val($.trim(selTypeText));  

	                var selTypeText = $("#CateId option:selected").text();
	                selTypeText = selTypeText.replace(/_/gi, '');
	                $("#CateName").val($.trim(selTypeText)); 
	            });
		    });
	</script> 

} 
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
   
<h2>Create</h2> 
    <fieldset>
         @Html.HiddenFor(model=>model.CateName)
        @Html.HiddenFor(model=>model.UserName)
        <legend>News</legend>
        
             <div style="color:red">@ViewBag.msg </div>
       
        <div class="editor-label">
              Nhóm tin
        </div>
        <div class="editor-field">
            @Html.DropDownList("CateId") 
        </div>

        <div class="editor-label">
           Tiêu đề
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Title)
            @Html.ValidationMessageFor(model => model.Title)
        </div>   
        <div class="editor-label">
              Mô tả
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>

        <div class="editor-label">
           Nội dung
        </div>
        <div class="editor-field" style="width:700px">
            @Html.TextAreaFor(model => model.Content, new { @class="ckeditor"})
            @Html.ValidationMessageFor(model => model.Content)
        </div>
        
        <div class="editor-label">
           Hiển thị
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Satus)
            @Html.ValidationMessageFor(model => model.Satus)
        </div>
        <div class="editor-label">
          Thứ tự
        </div>
        <div class="editor-field">            
            <input type="number" name="Orderby" value="0" id="Orderby" />
         
        </div>

        <div class="editor-label">
            Hình ảnh
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Image)
            <a href="@Upload" target="_parent"  onclick="window.open('@Upload', 'newwindow',  [ 'width=1024,height=700',
                            'width=1024,height=900,scrollbars=yes' ]); return false;">Tải ảnh</a>

        </div>


        <p>
            <input type="submit" value="Tạo tin" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Quay lại trang danh sách ", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
